package com.topsun.framework.common.core.util;

import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateUnit;

/**
 * 
 * @author: 皮皮
 * @date: 2021/5/7 2:45 PM
 */
public class DateUtil extends cn.hutool.core.date.DateUtil {

    /**
     * 格式化间隔时间
     * @param betweenTime 间隔时间，毫秒
     * @return
     */
    public static String formatBetweenTime(long betweenTime) {
        if (betweenTime < DateUnit.HOUR.getMillis()) {
            return formatBetween(betweenTime, BetweenFormatter.Level.MINUTE);
        }
        if (betweenTime < DateUnit.DAY.getMillis()) {
            return formatBetween(betweenTime, BetweenFormatter.Level.HOUR);
        }
        return formatBetween(betweenTime, BetweenFormatter.Level.DAY);
    }
}
